#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <malloc.h>

void *thread_print(void *arg)
{
  int i = 0;
  unsigned int *return_code = NULL;
  printf("This is son pthread, thread id = %u.\n", pthread_self());

  for (i = 0; i < 5; i++){
    printf("tid = %u, i = %d\n", pthread_self(), i);
  }
  
  return_code = (unsigned int*)malloc(sizeof(pthread_t));
  if (return_code == NULL) {
    printf("Fail to malloc for return_code\n");
    exit(-1);
  }
  *return_code = pthread_self();
  pthread_exit((void*)return_code);
}
